﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ScheduleContent.aspx.cs" Inherits="CourseManager.View.Contents.Teacher.ScheduleContent" %>
<%@ Register  Assembly="Ext.Net"  TagPrefix="ext" Namespace="Ext.Net" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
	<title>课表显示</title>
	<script type="text/javascript">

		function makeCourseMsg(courseId, teacherName, campus, place, credit, time) {
			return '课程号:&nbsp;&nbsp;&nbsp;' + courseId + '<br/>' +
					'教师:&nbsp;&nbsp;&nbsp;' + teacherName + '<br/>' +
					'学分:&nbsp;&nbsp;&nbsp;' + credit + '<br/>' +
					'时间:&nbsp;&nbsp;&nbsp;' + time + '<br/>' +
					'地点:&nbsp;&nbsp;&nbsp;' + campus + "&nbsp;" + place + "<br/>";
		}

		function DoSelect(courseId, courseName, tId, teacherName, campus, place, credit, time) {
			Ext.net.Notification.show({
				bringToFront: true,
				pinEvent: 'click',
				hideDelay: 3000,
				showPin: true,
				closeVisible: true,
				alignToCfg: {
					offset: [-10, -10],
					position: 'br-br',
					el: Ext.net.getEl('courseWindow')
				},
				height: 120,
				width: 200,
				html: makeCourseMsg(courseId, teacherName, campus, place, credit, time),
				title: courseName
			});
		}

	</script>
</head>
<body>
	<form id="Form1" runat="server">
	<ext:ResourceManager runat="server" />
	<ext:Store ID="Store" runat="server">
		<Reader>
			<ext:ArrayReader>
				<Fields>
					<ext:RecordField Name="Time" />
					<ext:RecordField Name="Monday" />
					<ext:RecordField Name="Tuesday" />
					<ext:RecordField Name="Wednesday" />
					<ext:RecordField Name="Thursday" />
					<ext:RecordField Name="Friday" />
					<ext:RecordField Name="Saturday" />
					<ext:RecordField Name="Sunday" />
				</Fields>
			</ext:ArrayReader>
		</Reader>
	</ext:Store>
	<ext:Store runat="server" ID="SelectedCouseStore">
		<Reader>
			<ext:JsonReader IDProperty="courseId,tId">
				<Fields>
					<ext:RecordField Name="tag" />
					<ext:RecordField Name="courseId" />
					<ext:RecordField Name="tId" />
					<ext:RecordField Name="courseName" />
					<ext:RecordField Name="teacherName" />
					<ext:RecordField Name="credit" />
					<ext:RecordField Name="time" />
					<ext:RecordField Name="campus" />
					<ext:RecordField Name="place" />
					<ext:RecordField Name="dept" />
					<ext:RecordField Name="capacity" />
				</Fields>
			</ext:JsonReader>
		</Reader>
	</ext:Store>
	<ext:CompositeField runat="server" Width="400">
		<Items>
			<ext:Label Text="选择学期: " Margins="14 10 10 10" runat="server" />
			<ext:ComboBox runat="server" ID="txtTermYear" Width="60" SelectOnFocus="true" ClearButton="true"
				BlankText="请选择或输入学年" SelectedIndex="0" Editable="false" Margins="10 10 10 0">
				<Items>
					<ext:ListItem Text="2008" Value="2008" />
					<ext:ListItem Text="2009" Value="2009" />
					<ext:ListItem Text="2010" Value="2010" />
					<ext:ListItem Text="2011" Value="2011" />
					<ext:ListItem Text="2012" Value="2012" />
				</Items>
			</ext:ComboBox>
			<ext:ComboBox runat="server" ID="txtTerm" Width="80" SelectOnFocus="true" ClearButton="true"
				Margins="10 0 10 10" Editable="false" SelectedIndex="0">
				<Items>
					<ext:ListItem Text="秋季学期" Value="0" />
					<ext:ListItem Text="冬季学期" Value="1" />
					<ext:ListItem Text="春季学期" Value="2" />
					<ext:ListItem Text="夏季学期" Value="3" />
				</Items>
			</ext:ComboBox>
			<ext:Button runat="server" Text="刷新" ID="btnRefresh" Icon="accept" Margins="10 0 10 10" >
				<Listeners>
					<Click Handler="if (!#{txtTermYear}.validate() || !#{txtTerm}.validate()) { return false;}" />
				</Listeners>
				<DirectEvents>
					<Click OnEvent="BtnRefreshClick">
						<EventMask ShowMask="true" Msg="正在添加,请稍后..." />
					</Click>
				</DirectEvents>
			</ext:Button>
		</Items>
	</ext:CompositeField>
	<ext:Hidden ID="txtSchedule" runat="server" />
	<ext:Window runat="server" Collapsible="true" Minimizable="true" Maximizable="true"
		Icon="Time" Closable="false" Title="课程表" Width="540" Height="332" X="10" Y="50"
		CenterOnLoad="false" Resizable="false" Layout="Fit">
		<Items>
			<ext:GridPanel ID="scheduleGird" runat="server" StoreID="Store" EnableColumnMove="false"
				DDGroup="scheduleGridDDGroup" EnableColumnResize="false" EnableHdMenu="false"
				StripeRows="true">
				<ColumnModel ID="ColumnModel1" runat="server">
					<Columns>
						<ext:Column Header="时间" Width="100" DataIndex="Time" Align="Center" Sortable="false" />
						<ext:Column Header="周一" Width="60" DataIndex="Monday" Align="Center" Sortable="false" />
						<ext:Column Header="周二" Width="60" DataIndex="Tuesday" Align="Center" Sortable="false" />
						<ext:Column Header="周三" Width="60" DataIndex="Wednesday" Align="Center" Sortable="false" />
						<ext:Column Header="周四" Width="60" DataIndex="Thursday" Align="Center" Sortable="false" />
						<ext:Column Header="周五" Width="60" DataIndex="Friday" Align="Center" Sortable="false" />
						<ext:Column Header="周六" Width="60" DataIndex="Saturday" Align="Center" Sortable="false" />
						<ext:Column Header="周日" Width="60" DataIndex="Sunday" Align="Center" Sortable="false" />
					</Columns>
				</ColumnModel>
				<SelectionModel>
					<ext:CellSelectionModel ID="ctl41">
						<Listeners>
							<CellSelect Handler="var value=#{scheduleGird}.getSelectionModel().getSelectedCell(); var row = value[0], col = value[1],text = #{txtSchedule}.value; if (col > 0 && row >= 0 && text[col * 13 + row] >= 'A') {var id = text.charCodeAt(col * 13 + row)-65; #{SelectedCoursePanel}.getSelectionModel().selectRow(id);}" />
						</Listeners>
					</ext:CellSelectionModel>
				</SelectionModel>
			</ext:GridPanel>
		</Items>
	</ext:Window>
	<ext:Window ID="courseWindow" runat="server" Collapsible="true" Minimizable="true"
		Maximizable="true" Icon="Bookmark" Closable="false" Title="任教课程" Width="360"
		Height="332" X="560" Y="50" CenterOnLoad="false" Layout="Fit">
		<Items>
			<ext:GridPanel runat="server" ID="SelectedCoursePanel" StoreID="SelectedCouseStore"
				StripeRows="true" EnableColumnMove="false" EnableHdMenu="false">
				<ColumnModel>
					<Columns>
						<ext:CommandColumn Width="25" Align="Center">
							<Commands>
								<ext:GridCommand Icon="BookDelete" CommandName="DeleteCourse" ToolTip-Text="退课" />
							</Commands>
						</ext:CommandColumn>
						<ext:Column Header="" Width="30" Align="Center" Sortable="false" DataIndex="tag" />
						<ext:Column Header="课程名" Width="110" Align="Center" Sortable="false" DataIndex="courseName" />
						<ext:Column Header="校区" Width="40" Align="Center" Sortable="false" DataIndex="campus" />
						<ext:Column Header="地点" Width="70" Align="Center" Sortable="false" DataIndex="place" />
						<ext:Column Header="学分" Width="40" Align="Center" Sortable="false" DataIndex="credit" />
					</Columns>
				</ColumnModel>
				<Listeners>
					<Command Handler="DoCommand(command, record.data.courseId, record.data.courseName, record.data.tId);" />
				</Listeners>
				<SelectionModel>
					<ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
						<Listeners>
							<RowSelect Handler="DoSelect(record.data.courseId, record.data.courseName, record.data.tId, record.data.teacherName, record.data.campus, record.data.place , record.data.credit, record.data.time)" />
						</Listeners>
					</ext:RowSelectionModel>
				</SelectionModel>
			</ext:GridPanel>
		</Items>
	</ext:Window>
	</form>
</body>
</html>
